From 615f10f7c8dbfd4431430d65ef7266e66d023a82 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 19 Dec 2018 19:26:04 +0100 Subject: [PATCH] revealer: Fully set the target state if unmapped during animation If the revealer is told do animate and then unrealize itself, we do (correctly) stop the animation, but used to do a shortcut where we just set the target state as current. Other things are dependent on the animation properly finishing though, like the contained widget child visibility. This may lead to inconsistent state where gtk_revealer_get_child_revealed() returns TRUE but the child widget is unmapped, or vice-versa. Fully finish the animation here, so the child state is coherent the next time the revealer is mapped. We can also skip notifying on the property since it will be handled by gtk_revealer_set_position(). --- gtk/gtkrevealer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gtk/gtkrevealer.c b/gtk/gtkrevealer.c index 92a33da868..d1245d22fb 100644 --- a/gtk/gtkrevealer.c +++ b/gtk/gtkrevealer.c @@ -111,6 +111,9 @@ static void gtk_revealer_measure (GtkWidget *widget, static void gtk_revealer_snapshot (GtkWidget *widget, GtkSnapshot *snapshot); +static void gtk_revealer_set_position (GtkRevealer *revealer, + gdouble pos); + G_DEFINE_TYPE_WITH_PRIVATE (GtkRevealer, gtk_revealer, GTK_TYPE_BIN) static void @@ -202,10 +205,8 @@ gtk_revealer_unmap (GtkWidget *widget) /* Finish & stop the animation */ if (priv->current_pos != priv->target_pos) - { - priv->current_pos = priv->target_pos; - g_object_notify_by_pspec (G_OBJECT (revealer), props[PROP_CHILD_REVEALED]); - } + gtk_revealer_set_position (revealer, priv->target_pos); + if (priv->tick_id != 0) { gtk_widget_remove_tick_callback (GTK_WIDGET (revealer), priv->tick_id); -- 2.30.2